<template>
	<view>
		<view class="order-status" :style="{color: order.orderStatusColor}">
			{{order.orderStatusDesc}}
		</view>
		<!-- 快递配送 -->
		<view class="address-section" v-if="order.deliveryType=='1'">
			<view class="order-content">
				<text class="yticon icon-shouhuodizhi"></text>
				<view class="cen">
					<view class="top">
						<text class="name">{{order.deliveryName}}</text>
						<text class="mobile">{{order.deliveryContactNo}}</text>
					</view>
					<text class="address">{{order.deliveryStreet}}</text>
				</view>
			</view>
			<image class="a-bg" src=""></image>
		</view>
		<!-- 门店自提 -->
		<view class="address-section" v-if="order.deliveryType=='2'">
			<view class="order-content">
				<text class="yticon icon-shouhuodizhi"></text>
				<view class="cen">
					<view class="top">
						<text class="name">{{order.merchantDTO.merchantName}}</text>
						<text class="mobile">{{order.merchantDTO.mobileNo}}</text>
					</view>
					<text class="address">{{order.merchantDTO.merchantAddress}}</text>
				</view>
			</view>
			<image class="a-bg" src=""></image>
		</view>

		<view class="goods-section">
			<!-- 商品列表 -->
			<view class="g-item" v-for="product in order.orderProductDTOList">
				<image @click="navProductDetail(product)" :src="product.productImageUrl"></image>
				<view class="right">
					<text class="title clamp">{{product.productName}}</text>
					<!-- <text class="spec" v-if="product.pointProductDTO.skuEnabled">
						<text v-for="sku in product.pointProductSkuDTO.skuAttrValueList">{{sku.skuAttrValue}}</text>
					</text>
					<text class="spec" v-if="!product.pointProductDTO.skuEnabled">-</text> -->
					<text class="spec" v-if="product.productSkuDesc">{{product.productSkuDesc}}</text>
					<text class="spec" v-if="!product.productSkuDesc">-</text>
					<view class="price-box">
						<text class="price" v-if="product.pointProductDTO.skuEnabled">{{product.pointProductSkuDTO.skuUnitPoint}}</text>
						<text class="price" v-if="!product.pointProductDTO.skuEnabled">{{product.pointProductDTO.unitPoint}}</text>
						<text class="number">x {{product.productUnit}}</text>
					</view>
				</view>
			</view>
		</view>

		<!-- 优惠明细 -->
		<!-- <view class="yt-list">
			<view class="yt-list-cell b-b">
				<view class="yt-list-cell b-b" @click="toggleMask('show')">
				<view class="cell-icon">
					券
				</view>
				<text class="cell-tit clamp">优惠券</text>
				<text class="cell-tip active">
					选择优惠券
				</text>
				<text class="cell-tip active">
					无可用优惠券
				</text>
				<text class="cell-more wanjia wanjia-gengduo-d"></text>
			</view>
			<view class="yt-list-cell b-b">
				<view class="cell-icon hb">
					减
				</view>
				<text class="cell-tit clamp">商家促销</text>
				<text class="cell-tip disabled">暂无可用优惠</text>
			</view>
		</view> -->
		<!-- 金额明细 -->
		<view class="yt-list">
			<view class="yt-list-cell b-b">
				<text class="cell-tit clamp">商品积分</text>
				<text class="cell-tip">{{order.actualPoint}}积分</text>
			</view>
			<view class="yt-list-cell b-b">
				<text class="cell-tit clamp">收货类型</text>
				<text class="cell-tip">{{order.deliveryTypeDesc}}</text>
			</view>
			<view class="yt-list-cell b-b">
				<text class="cell-tit clamp">运费</text>
				<text class="cell-tip">￥{{order.freightAmount}}</text>
			</view>
			<view class="yt-list-cell b-b">
				<text class="cell-tit clamp">实付金额</text>
				<text class="cell-tip red">￥{{order.actualAmount}}</text>
			</view>
		</view>
		
		<view class="yt-list">
			<view class="yt-list-cell b-b">
				<text class="cell-tit clamp">下单时间</text>
				<text class="cell-tip">{{order.orderTime}}</text>
			</view>
			<view class="yt-list-cell b-b">
				<text class="cell-tit clamp">订单编号</text>
				<text class="cell-tip">{{order.orderNo}}</text>
			</view>
			<view class="yt-list-cell b-b">
				<text class="cell-tit clamp">付款时间</text>
				<text class="cell-tip">{{order.paymentTime||''}}</text>
			</view>
			<view class="yt-list-cell b-b">
				<text class="cell-tit clamp">发货时间</text>
				<text class="cell-tip">{{order.deliveryTime||''}}</text>
			</view>
			<view class="yt-list-cell b-b">
				<text class="cell-tit clamp">收货时间</text>
				<text class="cell-tip">{{order.confirmTime||''}}</text>
			</view>
			<view class="yt-list-cell desc-cell">
				<text class="cell-tit clamp">备注</text>
				<text class="cell-tip red">{{order.memo}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		data() {
			return {
				orderNo: '',
				order: {}
			}
		},
		onLoad(option) {
			//订单数据
			this.orderNo = option.orderNo;
			this.inquiryOrder(this.orderNo);
		},
		computed: {
			...mapState(['hasLogin', 'userInfo'])
		},
		methods: {
			//查询订单
			inquiryOrder(orderNo) {
				this.$api.request.orderDetail({
					orderNo: orderNo
				}, res => {
					if (res.body.status.statusCode === '0') {
						this.order = res.body.data;
						this.order.orderStatusDesc = this.$api.util.translateOrderStatus(this.order.orderStatus).orderStatusDesc;
						this.order.orderStatusColor = this.$api.util.translateOrderStatus(this.order.orderStatus).orderStatusColor;
					} else {
						console.log(res.body.status.errorDesc);
					}
				});
			},
			navProductDetail(item){
				uni.navigateTo({
					url: '/pages/point/product-detail?id='+item.pointProductDTO.productUuid
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background: $page-color-base;
		padding-bottom: 100upx;
	}
	
	.order-status{
		background: #fff;
		padding: 5px 15px 5px 20px;
		color: #333;
		font-size: 16px;
		font-weight: bold;
	}
	
	.address-section {
		padding: 30upx 0;
		background: #fff;
		position: relative;

		.order-content {
			display: flex;
			align-items: center;
		}

		.icon-shouhuodizhi {
			flex-shrink: 0;
			display: flex;
			align-items: center;
			justify-content: center;
			width: 90upx;
			color: #888;
			font-size: 44upx;
		}

		.cen {
			display: flex;
			flex-direction: column;
			flex: 1;
			font-size: 28upx;
			color: $font-color-dark;
		}

		.name {
			font-size: 34upx;
			margin-right: 24upx;
		}

		.address {
			margin-top: 16upx;
			margin-right: 20upx;
			color: $font-color-light;
		}

		.icon-you {
			font-size: 32upx;
			color: $font-color-light;
			margin-right: 30upx;
		}

		.a-bg {
			position: absolute;
			left: 0;
			bottom: 0;
			display: block;
			width: 100%;
			height: 5upx;
		}
	}

	.goods-section {
		margin-top: 16upx;
		background: #fff;
		padding-bottom: 1px;

		.g-header {
			display: flex;
			align-items: center;
			height: 84upx;
			padding: 0 30upx;
			position: relative;
		}

		.logo {
			display: block;
			width: 50upx;
			height: 50upx;
			border-radius: 100px;
		}

		.name {
			font-size: 30upx;
			color: $font-color-base;
			margin-left: 24upx;
		}

		.g-item {
			display: flex;
			margin: 20upx 30upx;

			image {
				flex-shrink: 0;
				display: block;
				width: 140upx;
				height: 140upx;
				border-radius: 4upx;
			}

			.right {
				flex: 1;
				padding-left: 24upx;
				overflow: hidden;
			}

			.title {
				font-size: 30upx;
				color: $font-color-dark;
			}

			.spec {
				font-size: 26upx;
				color: $font-color-light;
			}

			.price-box {
				display: flex;
				align-items: center;
				font-size: 32upx;
				color: $font-color-dark;
				padding-top: 10upx;

				.price {
					margin-bottom: 4upx;
					&:after {
						content: '积分';
						font-size: $font-sm;
						margin: 0 2upx 0 8upx;
					}
				}

				.number {
					font-size: 26upx;
					color: $font-color-base;
					margin-left: 20upx;
				}
			}

			.step-box {
				position: relative;
			}
		}
	}

	.yt-list {
		margin-top: 16upx;
		background: #fff;
	}

	.yt-list-cell {
		display: flex;
		align-items: center;
		padding: 10upx 30upx 10upx 40upx;
		line-height: 70upx;
		position: relative;

		&.cell-hover {
			background: #fafafa;
		}

		&.b-b:after {
			left: 30upx;
		}

		.cell-icon {
			height: 32upx;
			width: 32upx;
			font-size: 22upx;
			color: #fff;
			text-align: center;
			line-height: 32upx;
			background: #f85e52;
			border-radius: 4upx;
			margin-right: 12upx;

			&.hb {
				background: #ffaa0e;
			}

			&.lpk {
				background: #3ab54a;
			}

		}

		.cell-more {
			align-self: center;
			font-size: 24upx;
			color: $font-color-light;
			margin-left: 8upx;
			margin-right: -10upx;
		}

		.cell-tit {
			flex: 1;
			font-size: 26upx;
			color: $font-color-light;
			margin-right: 10upx;
		}

		.cell-tip {
			font-size: 26upx;
			color: $font-color-dark;

			&.disabled {
				color: $font-color-light;
			}

			&.active {
				color: $base-color;
			}

			&.red {
				color: $base-color;
			}
		}

		&.desc-cell {
			.cell-tit {
				max-width: 90upx;
			}
		}

		.desc {
			flex: 1;
			font-size: $font-base;
			color: $font-color-dark;
		}
	}

	/* 支付列表 */
	.pay-list {
		padding-left: 40upx;
		margin-top: 16upx;
		background: #fff;

		.pay-item {
			display: flex;
			align-items: center;
			padding-right: 20upx;
			line-height: 1;
			height: 110upx;
			position: relative;
		}

		.icon-weixinzhifu {
			width: 80upx;
			font-size: 40upx;
			color: #6BCC03;
		}

		.icon-alipay {
			width: 80upx;
			font-size: 40upx;
			color: #06B4FD;
		}

		.icon-xuanzhong2 {
			display: flex;
			align-items: center;
			justify-content: center;
			width: 60upx;
			height: 60upx;
			font-size: 40upx;
			color: $base-color;
		}

		.tit {
			font-size: 32upx;
			color: $font-color-dark;
			flex: 1;
		}
	}
</style>
